//
//  MouoSinaMenuToolView.m
//  WJSinaHomeMenu
//
//  Created by tqh on 2019/5/16.
//  Copyright © 2019 tqh. All rights reserved.
//

#import "MouoSinaMenuToolView.h"
#import "HexColors.h"
#import "UIView+Extension.h"
@interface MouoSinaMenuToolView ()

@property (nonatomic,strong) UIButton *editButton;

@end

@implementation MouoSinaMenuToolView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creqateView];
    }
    return self;
}

- (void)creqateView {
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(15, 0, 100, 50)];
    label.text = @"我的分类";
    label.textColor = [UIColor colorWithHexString:@"#9B9B9B"];
    label.font = [UIFont systemFontOfSize:14];
    [self addSubview:label];
    
    UIButton *cancelButton = [[UIButton alloc]initWithFrame:CGRectMake(self.width - 50, 0, 50, 50)];
    [cancelButton setImage:[UIImage imageNamed:@"delete"] forState:UIControlStateNormal];
    [cancelButton addTarget:self action:@selector(cancelButtonPressed) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:cancelButton];
    
    UIButton *editButton = [[UIButton alloc]initWithFrame:CGRectMake(cancelButton.x - 50, 0, 40, 50)];
    [editButton setTitle:@"编辑" forState:UIControlStateNormal];
    [editButton setTitle:@"完成" forState:UIControlStateSelected];
    editButton.titleLabel.font = [UIFont systemFontOfSize:15];
    [editButton setTitleColor:[UIColor colorWithHexString:@"#2296F3"] forState:UIControlStateNormal];
    [editButton addTarget:self action:@selector(editButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:editButton];
    self.editButton = editButton;
    
}

- (void)resetData {
    self.editButton.selected = NO;
}

- (void)editButtonPressed:(UIButton *)sender {
    sender.selected = !sender.selected;
    if (self.delegate && [self.delegate respondsToSelector:@selector(mouoSinaMenuToolViewDidEdit:)]) {
        [self.delegate mouoSinaMenuToolViewDidEdit:sender.selected];
    }
}

- (void)cancelButtonPressed {
    if (self.delegate && [self.delegate respondsToSelector:@selector(mouoSinaMenuToolViewDidClose)]) {
        [self.delegate mouoSinaMenuToolViewDidClose];
    }
}

@end
